package top.ninwoo.edgecenter.service.impl;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import top.ninwoo.common.EdgeNodeEntity;
import top.ninwoo.edgecenter.register.Register;
import top.ninwoo.edgecenter.service.EdgeService;
import top.ninwoo.utils.util.impl.IpUtils;

@Service
public class EdgeServiceImpl implements EdgeService {

    @Value("${bs.edgenode.name}")
    private String edgeNodeName;

    @Value("${server.port}")
    private int port;

    @Value("${bs.edgenode.ip-prefix}")
    private String ipPrefix;

    @Override
    public EdgeNodeEntity info() {
        // TODO: 需要添加真实的功能
        EdgeNodeEntity edgeNodeEntity = new EdgeNodeEntity();
        // TODO: 这里的id考虑是否
        edgeNodeEntity.setId(11111);
        edgeNodeEntity.setName(edgeNodeName);
        edgeNodeEntity.setUrl("http://" + IpUtils.getHostIp(ipPrefix) + ":" + port);

        return edgeNodeEntity;
    }
}
